using FluentNHibernate.Mapping;
using RMH.Entities;

namespace RMH.DataAccess.Mappings
{
    public class StayMap: ClassMap<Stay>
    {
        public StayMap()
        {
            Id(x => x.Id);
            Map(x => x.HospitalUnit);
            Map(x => x.HospitalRoomNumber);
            Map(x => x.HospitalPhoneNumber);
            Map(x => x.MedicaidNumber);
            Map(x => x.SocialWorkerName);
            Map(x => x.CheckinDate);
            Map(x => x.CheckoutDate);
            Map(x => x.CheckinBy);
            Map(x => x.CheckoutBy);
            Map(x => x.PreauthorizationSentDate);
            Map(x => x.PreauthorizationApprovedDate);
            
            References(x => x.Patient).Cascade.SaveUpdate().FetchType.Join();
            References(x => x.Room).Cascade.SaveUpdate();
            References(x => x.Payment).Cascade.SaveUpdate();
            
            DynamicInsert();
            DynamicUpdate();
        }
    }
}